home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 2.5 KB | 112 lines | [TEXT/CWIE] |
- /*
- File: TrapUtils.c
-
- Contains: Functions to help you when you are building and sending Apple events.
-
- Written by:
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/22/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- // System includes
- #include <OSUtils.h>
- #include <Traps.h>
-
- // Utility routines
- #include "TrapUtils.h"
-
-
- // ===============================================================================
-
- static pascal UInt16 CountToolboxTraps( void )
- {
- static UInt16 trapCount;
-
- if ( !trapCount )
- {
- if ( GetToolTrapAddress( _InitGraf ) == GetToolTrapAddress( 0xAA6E ) )
- {
- trapCount = 0x0200;
- }
- else
- {
- trapCount = 0x0400;
- }
- }
-
- return trapCount;
- }
-
- // ===============================================================================
-
- static pascal TrapType GetTrapType( UInt16 trapWord )
- {
- if ( trapWord & 0x0800 )
- {
- return ToolTrap;
- }
- else
- {
- return OSTrap;
- }
- }
-
- // ===============================================================================
-
- pascal Boolean TrapAvailable( UInt16 trapWord )
- {
- if ( GetTrapType( trapWord ) == OSTrap )
- {
- return GetToolTrapAddress( _Unimplemented ) != GetOSTrapAddress( trapWord );
- }
- else if ( ( trapWord & 0x07FF ) >= CountToolboxTraps () )
- {
- return false;
- }
- else
- {
- return GetToolTrapAddress( _Unimplemented ) != GetToolTrapAddress ( trapWord );
- }
- }
-
- // ===============================================================================
-
- pascal void * MyGetTrapAddress( UInt16 trapWord )
- {
- if ( GetTrapType( trapWord ) == OSTrap )
- {
- return GetOSTrapAddress( trapWord );
- }
- else
- {
- return GetToolTrapAddress( trapWord );
- }
- }
-
- // ===============================================================================
-
- pascal void MySetTrapAddress( UInt16 trapWord, void *newAddr )
- {
- if ( GetTrapType( trapWord ) == OSTrap )
- {
- SetOSTrapAddress( newAddr, trapWord );
- }
- else
- {
- SetToolTrapAddress( newAddr, trapWord );
- }
- }
-
-